package com.xbh.common.base;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.Date;

/**
 * @program: common-utils
 * @description:
 * @author: 许宝华
 * @create: 2021-08-29 19:22
 */

public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableField(
            fill = FieldFill.INSERT
    )
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonFormat(
            shape = JsonFormat.Shape.STRING,
            pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8"
    )
    private Date createTime;
    @TableField(
            fill = FieldFill.INSERT_UPDATE
    )
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonFormat(
            shape = JsonFormat.Shape.STRING,
            pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8"
    )
    private Date updateTime;
    private int deleted;
    private String createPerson;
    private String updatePerson;

    public BaseEntity() {
    }

    public Date getCreateTime() {
        return this.createTime;
    }

    public Date getUpdateTime() {
        return this.updateTime;
    }

    public int getDeleted() {
        return this.deleted;
    }

    public String getCreatePerson() {
        return this.createPerson;
    }

    public String getUpdatePerson() {
        return this.updatePerson;
    }

    @JsonFormat(
            shape = JsonFormat.Shape.STRING,
            pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8"
    )
    public void setCreateTime(final Date createTime) {
        this.createTime = createTime;
    }

    @JsonFormat(
            shape = JsonFormat.Shape.STRING,
            pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8"
    )
    public void setUpdateTime(final Date updateTime) {
        this.updateTime = updateTime;
    }

    public void setDeleted(final int deleted) {
        this.deleted = deleted;
    }

    public void setCreatePerson(final String createPerson) {
        this.createPerson = createPerson;
    }

    public void setUpdatePerson(final String updatePerson) {
        this.updatePerson = updatePerson;
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof BaseEntity)) {
            return false;
        } else {
            BaseEntity other = (BaseEntity)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getDeleted() != other.getDeleted()) {
                return false;
            } else {
                label61: {
                    Object this$createTime = this.getCreateTime();
                    Object other$createTime = other.getCreateTime();
                    if (this$createTime == null) {
                        if (other$createTime == null) {
                            break label61;
                        }
                    } else if (this$createTime.equals(other$createTime)) {
                        break label61;
                    }

                    return false;
                }

                label54: {
                    Object this$updateTime = this.getUpdateTime();
                    Object other$updateTime = other.getUpdateTime();
                    if (this$updateTime == null) {
                        if (other$updateTime == null) {
                            break label54;
                        }
                    } else if (this$updateTime.equals(other$updateTime)) {
                        break label54;
                    }

                    return false;
                }

                Object this$createPerson = this.getCreatePerson();
                Object other$createPerson = other.getCreatePerson();
                if (this$createPerson == null) {
                    if (other$createPerson != null) {
                        return false;
                    }
                } else if (!this$createPerson.equals(other$createPerson)) {
                    return false;
                }

                Object this$updatePerson = this.getUpdatePerson();
                Object other$updatePerson = other.getUpdatePerson();
                if (this$updatePerson == null) {
                    if (other$updatePerson != null) {
                        return false;
                    }
                } else if (!this$updatePerson.equals(other$updatePerson)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof BaseEntity;
    }

    public int hashCode() {
        boolean PRIME = true;
        int result = 1;
        result = result * 59 + this.getDeleted();
        Object $createTime = this.getCreateTime();
        result = result * 59 + ($createTime == null ? 43 : $createTime.hashCode());
        Object $updateTime = this.getUpdateTime();
        result = result * 59 + ($updateTime == null ? 43 : $updateTime.hashCode());
        Object $createPerson = this.getCreatePerson();
        result = result * 59 + ($createPerson == null ? 43 : $createPerson.hashCode());
        Object $updatePerson = this.getUpdatePerson();
        result = result * 59 + ($updatePerson == null ? 43 : $updatePerson.hashCode());
        return result;
    }

    public String toString() {
        return "BaseEntity(createTime=" + this.getCreateTime() + ", updateTime=" + this.getUpdateTime() + ", deleted=" + this.getDeleted() + ", createPerson=" + this.getCreatePerson() + ", updatePerson=" + this.getUpdatePerson() + ")";
    }
}
